<?php 
require_once("checklogin.php");
require_once("classQuanTriTin.php");
$qt = new quantritin;
//$tin= $qt->ListTin();
$idTL=-1; if (isset($_GET['idTL'])==true) $idTL = $_GET['idTL']; settype($idTL,"int");
$idLT=-1; if (isset($_GET['idLT'])==true) $idLT = $_GET['idLT']; settype($idLT,"int");
$lang=''; if (isset($_GET['lang'])==true) $lang = $_GET['lang'];
if (get_magic_quotes_gpc()==false) $lang = mysql_real_escape_string($lang);


$tin = $qt->ListTin($idTL,$idLT,$lang);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>List tin xem danh sach</title>
<style>
#dstin th { background-color:#033; color:#CF3; }
.tin p{margin-top:5px;  margin-bottom:5px; text-align:justify; color:#660; }
.tin p:first-child{font-weight:bold; color:#C60;}
.tin p:first-child span{ font-style:italic; color:#060; font-size:14px}
p.tomtat:first-line { color:#06C}
p.tomtat:first-letter { font-size:22px; color:#C0C; font-weight:bold}
.action a{ color:#033; text-decoration:none}
.action a:hover{ color:#630; text-decoration:underline}
.hightlight {background:#FFFF00;}
.them {	font-weight: bold;color: #FFFFFF; background-color: #FF9900;
		display: block; height: 22px; width: 50px; text-decoration: none;
		line-height: 22px; font-size: 14px; text-align: center; float:left;
}
.themtin {float: left; width: 50px;}
</style>
<script type="text/javascript" src="../Scripts/jquery.js"></script>
<script>
$(document).ready(function(){
	$("#chonhet").click(function(){
		var status = this.checked;
		$("input[name='chon']").each(function(){this.checked=status;})
	});
	$(".hang").mouseover(function(){ $(this).addClass("hightlight");  });
	$(".hang").mouseout(function(){	 $(this).removeClass("hightlight"); });
	$("#xoahet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
	   })
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		hoi= confirm("Xoá hết hả");
		if (hoi==true) document.location = "tintuc_xoa.php?listid=" + listid;
	});
	$("#chinhhet").click(function(){
		var listid = "";
		$("input[name='chon']").each(function(){
			if (this.checked) listid = listid + "," + this.value;
		});
		listid = listid.substr(1);	 //alert(listid);
		if (listid=="") { alert("Bạn chưa chọn tin nào"); return;}
		document.location = "tintuc_chinhhet.php?listid=" + listid;
	});

});
</script>	
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table id=dstin  border=1 cellpadding=4  cellspacing=0  width=800  align=center>
<tr>
  <td colspan="3" align="left">
      <input type="button" name="xoahet" id="xoahet" value=" Xoá " />
      <input type="button" name="chinhhet" id="chinhhet" value="Chỉnh" />     
  </td>
  <td align="right"> 
<select name="themtin" class="themtin" id="themtin">
    <option value="1">1</option> <option value="2">2</option>
    <option value="3">3</option> <option value="4">4</option>
    <option value="5">5</option>
</select>
<a href="#" onClick="return false" class="them" id="them">Thêm</a>
  </td>
</tr>
<tr>
   <th align="left"><input type="checkbox" name="chonhet" id="chonhet" /></th>
   <th> idTin/Ngày </th>
   <th> Tiêu đề/Tóm tắt </th>
   <th> Action </th>
</tr>

<!—bắt đầu lặp -->
<?php while ($row_tin = mysql_fetch_assoc($tin)) { ?>
<?php ob_start(); ?>

<tr class="hang">
   <td><input type="checkbox" name="chon" id="chon" value="{idTin}" class="chon" /></td>
   <td align="center" class="ngay">
	<span>idTin: {idTin} </span><br /> 
	<span>{Ngay} </span> <br /> 
<span>Xem: {SoLanXem} </span>
   </td>
   <td class="tin" valign=top>
     <p class="tieude">{TieuDe}   <span> ({TenTL} </span> / <span> {Ten}) </span> </p>
     <p class="tomtat">{TomTat}</p> 
   </td>
   <td width="100" align="center" class="action">
    | <a href="tintuc_chinh1.php?idTin={idTin}">Chỉnh</a> 
    | <a href="tintuc_xoa.php?idTin={idTin}"  onclick="return confirm('Xoá hả');">Xóa</a> |
      <a href="tintuc_xemchitiet.php?idTin={idTin}">Xem</a><br />
      <img src="AnHien_{AnHien}.gif" title="Ẩn hiện tin" class="anhien" value="{idTin}" />
	&nbsp; 
	<img src="NoiBat_{TinNoiBat}.jpg" title="Tin nổi bật" class="noibat" 	value="{idTin}">
   </td>
</tr>
<?php 	
$str=ob_get_clean(); 
$str=str_replace("{idTin}", $row_tin['idTin'] , $str);
$str=str_replace("{Ngay}",date('d/m/Y',strtotime($row_tin['Ngay'])) , $str);
$str=str_replace("{TieuDe}", $row_tin['TieuDe'] , $str);
$str=str_replace("{TomTat}", $row_tin['TomTat'] , $str);
$str=str_replace("{SoLanXem}", $row_tin['SoLanXem'] , $str);
$str=str_replace("{AnHien}", $row_tin['AnHien'] , $str);
$str=str_replace("{TinNoiBat}", $row_tin['TinNoiBat'] , $str);
$str=str_replace("{TenTL}", $row_tin['TenTL'] , $str);
$str=str_replace("{Ten}", $row_tin['Ten'] , $str);
echo $str;
?>
<?php } ?>

<!— kết thúc lặp -->

</table>
</form>
</body>
</html>
